# coding: utf-8
import os, sys
from PyQt4 import QtCore, QtGui, uic

class DialogDate (QtGui.QDialog):
    def __init__(self, *args):
        super(DialogDate, self).__init__(*args)
        
        uic.loadUi("dialogdate.ui", self)

class DialogAdd (QtGui.QDialog):
    def __init__(self, *args):
        super(DialogAdd, self).__init__(*args)
        self.dataid = 0
        uic.loadUi("dialogadd.ui", self)
        self.date.setDate(QtCore.QDate.currentDate())
        self.time.setTime(QtCore.QTime.currentTime())
    
    def setdata(self, data):
        self.title.setText(data['title'])
        dt = data['date']
        self.date.setDate(QtCore.QDate(dt[0], dt[1], dt[2]))
        tm = data['time']
        self.time.setTime(QtCore.QTime(tm[0], tm[1], 0))
        if data['loop']:
            self.check.setChecked()
        self.message.setText(data['msg'])
        self.dataid = data['id']

    @QtCore.pyqtSlot()
    def on_choosedate_clicked(self):
        dlg = DialogDate(self)
        dlg.setModal(True)

        if dlg.exec_():
            date = dlg.calendar.selectedDate()
            self.date.setDate(date)

        dlg.destroy()


